package com.jshoperxms.controller.mall.backstage.topic;

import com.jshoperxms.Response;
import com.jshoperxms.controller.mall.backstage.base.BaseTController;
import com.jshoperxms.controller.mall.backstage.base.IBaseCtrl;
import com.jshoperxms.controller.mall.backstage.base.SearchModel;
import com.jshoperxms.controller.utils.statickey.TagWords;
import com.jshoperxms.controller.utils.statickey.WarnWrods;
import com.jshoperxms.entity.TopicArticleT;
import com.jshoperxms.service.TopicArticleTService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by sdywcd on 16/11/22.
 * Des:
 */
@Controller
@RequestMapping("/mall/topicarticle")
public class TopicArticleTController extends BaseTController implements IBaseCtrl<TopicArticleT> {

    @Resource
    private TopicArticleTService topicArticleTService;
    private Map<String,Object> responsedata=new HashMap<>();


    @RequestMapping(value="/save",method= RequestMethod.POST)
    @Override
    public ResponseEntity save(@RequestBody TopicArticleT rq){
        if(StringUtils.isBlank(rq.getTopiclabels())){
            responsedata.put(TagWords.SUCCESS,false);
            responsedata.put(TagWords.MSG, WarnWrods.ERROR_PARAMS);
        }else{
            this.topicArticleTService.saveTopicArticleTransactional(rq);
            responsedata.put(TagWords.SUCCESS, true);
            responsedata.put(TagWords.MSG, TagWords.OPERATION_SUCCESS);
        }
        return Response.success(responsedata);
    }

    @Override
    public ResponseEntity find(@RequestBody TopicArticleT rq) {
        return null;
    }

    @Override
    public ResponseEntity del(@RequestBody TopicArticleT rq) {
        return null;
    }

    @Override
    public ResponseEntity update(@RequestBody TopicArticleT rq) throws ParseException {
        return null;
    }

    @Override
    public ResponseEntity findAll() {
        return null;
    }

    @Override
    public ResponseEntity findByPage(SearchModel searchModel, @RequestParam("search[value]") String search, @RequestParam("order[0][column]") String ordervalue, @RequestParam("order[0][dir]") String ordertype) {
        return null;
    }

    @Override
    public void findCustomSearch(SearchModel searchModel, String search, String ordervalue, String ordertype) {

    }

    @Override
    public void filterSearch(SearchModel searchModel, String search) {

    }

    @Override
    public void findDefaultAll(SearchModel searchModel, String ordervalue, String ordertype) {

    }

    @Override
    public void processPageList(List<TopicArticleT> list) {

    }

    @Override
    public boolean checkDuplicates(String str) {
        return false;
    }
}
